//
//  NSObject+NNAddAttribute.m
//  MyFramework
//
//  Created by 余洋 on 2018/8/14.
//  Copyright © 2018年 余洋. All rights reserved.
//
#import "NSObject+NNAddAttribute.h"
#import <objc/message.h>

@implementation NSObject (NNAddAttribute)

- (void)setName:(NSString *)name {
    // 相当于 setValue:forKey 进行关联value对象
    objc_setAssociatedObject(self, @"name", name, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (NSString *)name {
    return objc_getAssociatedObject(self, @"name");
}

@end
